package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TZhgdDeviceToolsStorage;
import com.ruoyi.system.service.ITZhgdDeviceToolsStorageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工器具明细Controller
 * 
 * @author wuyafeng
 * @date 2025-01-16
 */
@Controller
@RequestMapping("/system/storage")
public class TZhgdDeviceToolsStorageController extends BaseController
{
    private String prefix = "system/storage";

    @Autowired
    private ITZhgdDeviceToolsStorageService tZhgdDeviceToolsStorageService;

    @RequiresPermissions("system:storage:view")
    @GetMapping()
    public String storage()
    {
        return prefix + "/storage";
    }

    /**
     * 查询工器具明细列表
     */
    @RequiresPermissions("system:storage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TZhgdDeviceToolsStorage tZhgdDeviceToolsStorage)
    {
        startPage();
        List<TZhgdDeviceToolsStorage> list = tZhgdDeviceToolsStorageService.selectTZhgdDeviceToolsStorageList(tZhgdDeviceToolsStorage);
        return getDataTable(list);
    }

    /**
     * 导出工器具明细列表
     */
    @RequiresPermissions("system:storage:export")
    @Log(title = "工器具明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TZhgdDeviceToolsStorage tZhgdDeviceToolsStorage)
    {
        List<TZhgdDeviceToolsStorage> list = tZhgdDeviceToolsStorageService.selectTZhgdDeviceToolsStorageList(tZhgdDeviceToolsStorage);
        ExcelUtil<TZhgdDeviceToolsStorage> util = new ExcelUtil<TZhgdDeviceToolsStorage>(TZhgdDeviceToolsStorage.class);
        return util.exportExcel(list, "工器具明细数据");
    }

    /**
     * 新增工器具明细
     */
    @RequiresPermissions("system:storage:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存工器具明细
     */
    @RequiresPermissions("system:storage:add")
    @Log(title = "工器具明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TZhgdDeviceToolsStorage tZhgdDeviceToolsStorage)
    {
        return toAjax(tZhgdDeviceToolsStorageService.insertTZhgdDeviceToolsStorage(tZhgdDeviceToolsStorage));
    }

    /**
     * 修改工器具明细
     */
    @RequiresPermissions("system:storage:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TZhgdDeviceToolsStorage tZhgdDeviceToolsStorage = tZhgdDeviceToolsStorageService.selectTZhgdDeviceToolsStorageById(id);
        mmap.put("tZhgdDeviceToolsStorage", tZhgdDeviceToolsStorage);
        return prefix + "/edit";
    }

    /**
     * 修改保存工器具明细
     */
    @RequiresPermissions("system:storage:edit")
    @Log(title = "工器具明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TZhgdDeviceToolsStorage tZhgdDeviceToolsStorage)
    {
        return toAjax(tZhgdDeviceToolsStorageService.updateTZhgdDeviceToolsStorage(tZhgdDeviceToolsStorage));
    }

    /**
     * 删除工器具明细
     */
    @RequiresPermissions("system:storage:remove")
    @Log(title = "工器具明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tZhgdDeviceToolsStorageService.deleteTZhgdDeviceToolsStorageByIds(ids));
    }
}
